﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Common.Model
{
    public class EntityValidation
    {
        public static String Validate(object obj)
        {
            StringBuilder strBld = new StringBuilder();
            IDataErrorInfo idei = obj as IDataErrorInfo;
            if (idei != null)
            {
                foreach (var prop in obj.GetType().GetProperties())
                {
                    var str = idei[prop.Name];
                    if (!String.IsNullOrEmpty(str))
                    {
                        strBld.AppendLine(str);
                    }
                }
            }
            return strBld.ToString();
        }
    }
}
